//
//  ExpertListTableViewCell.m
//  yonghu
//
//  Created by mac on 2018/5/24.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "ExpertListTableViewCell.h"

@implementation ExpertListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)creatView{
    self.backgroundColor=_LightGrey;
    
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.mas_equalTo(10);
        make.right.mas_equalTo(-5);
        make.bottom.mas_equalTo(0);
    }];
    beiJingView.layer.cornerRadius=5;
    beiJingView.backgroundColor=[UIColor whiteColor];
    
    UIImageView *imageview=[UIImageView new];
    [beiJingView addSubview:imageview];
    [imageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.height.mas_equalTo(60);
    }];
    imageview.layer.cornerRadius=3;
    NSString *waiter_icon=[_dic objectForKey:@"waiter_icon"];
    NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",_addressUrl,waiter_icon]];
    [imageview sd_setImageWithURL:url];
    
    UILabel *nameLabel=[UILabel new];
    [beiJingView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageview.mas_right).mas_equalTo(6);
        make.top.mas_equalTo(imageview);
    }];
    nameLabel.text=[_dic objectForKey:@"waiter_name"];
    nameLabel.textColor=ColorWithRGB(49, 49, 49);
    nameLabel.font=[UIFont systemFontOfSize:17];
    
    NSNumber *evaluate_score=[_dic objectForKey:@"evaluate_score"];
    int typeNum2=evaluate_score.doubleValue*10;
    int typeNum=typeNum2%10;
    int index=5-evaluate_score.floatValue;
    
    
    for (int i=0; i<5; i++) {
        UIImageView *xingImage=[UIImageView new];
        [beiJingView addSubview:xingImage];
        [xingImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-10-25*i);
            make.height.width.mas_equalTo(20);
            make.centerY.mas_equalTo(nameLabel);
        }];
        
        if (typeNum>0) {
            if (i<index) {
                xingImage.image=[UIImage imageNamed:@"评分1"];
            }
            if (i==index) {
                xingImage.image=[UIImage imageNamed:@"评分3"];
            }
            if (i>index) {
                xingImage.image=[UIImage imageNamed:@"评分2"];
            }
        }
        else{
            if (i<index) {
                xingImage.image=[UIImage imageNamed:@"评分1"];
            }
            else{
                xingImage.image=[UIImage imageNamed:@"评分2"];
            }
        }
    }
    
    UILabel *pingFen=[UILabel new];
    [beiJingView addSubview:pingFen];
    [pingFen mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(nameLabel);
        make.right.mas_equalTo(-140);
    }];
    pingFen.text=@"评分:";
    pingFen.textColor=ColorWithRGB(149, 149, 149);
    pingFen.font=[UIFont systemFontOfSize:16];
    
    
    
    UIImageView *addImage=[UIImageView new];
    [beiJingView addSubview:addImage];
    [addImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.bottom.mas_equalTo(imageview.mas_bottom);
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(20);
    }];
    addImage.image=[UIImage imageNamed:@"location"];
    
    UILabel *label=[UILabel new];
    [beiJingView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(addImage.mas_right).mas_equalTo(20);
        make.centerY.mas_equalTo(addImage);
    }];
    label.text=[_dic objectForKey:@"we_city_name"];
    label.font=[UIFont systemFontOfSize:17];
    label.textColor=ColorWithRGB(149, 149, 149);
    
    UILabel *labelad=[UILabel new];
    [beiJingView addSubview:labelad];
    [labelad mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(imageview.mas_bottom).mas_equalTo(10);
    }];
    labelad.text=[_dic objectForKey:@"we_skilful"];
    labelad.font=[UIFont systemFontOfSize:15];
    labelad.textColor=ColorWithRGB(149, 149, 149);
}

@end
